package com.insurance.modules.claim.vo.convert;

import cn.hutool.core.date.DateUtil;
import com.aliyun.oss.model.PutBucketImageRequest;
import org.mapstruct.Named;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * mapstruct  自定义一些转换
 */
@Component
@Named("CustomConvert")
public class CustomConvert {

    /**
     * 保障状态：1在保 0过期
     * @param type
     * @return
     */
    @Named("convertInsuranceStatus")
    public static String convertInsuranceStatus(Integer type) {
        if(null == type){
            return null;
        }
        return type == 1 ? "在保":"过期";
    }

    /**
     * 人员类别：1有社保 0无社保
     * @param type
     * @return
     */
    @Named("convertPersonnelSort")
    public static String convertPersonnelSort(Integer type) {
        if(null == type){
            return null;
        }
        return type == 1 ? "有社保":"无社保";
    }


    /**
     * 是否外包：1是 0否
     * @param type
     * @return
     */
    @Named("convertOutsourcingFlag")
    public static String convertOutsourcingFlag(Integer type) {
        if(null == type){
            return null;
        }
        return type == 1 ? "是":"否";
    }

    /**
     * 事故类型 1医疗 2伤残 3死亡
     * @param type
     * @return
     */
    @Named("convertAccidentType")
    public static String convertAccidentType(Integer type) {
        if(null == type){
            return null;
        }
        switch (type){
            case 1:
                return "医疗";
            case 2:
                return "伤残";
            default:
                return "死亡";
        }
    }

    /**
     * 事故性质：1工作中意外 2上下班途中意外 3工作中交通事故 4上下班途中交通事故 5突发疾病
     * @param type
     * @return
     */
    @Named("convertAccidentNature")
    public static String convertAccidentNature(Integer type) {
        if(null == type){
            return null;
        }
        switch (type){
            case 1:
                return "工作中意外";
            case 2:
                return "上下班途中意外";
            case 3:
                return "工作中交通事故";
            case 4:
                return "上下班途中交通事故";
            default:
                return "突发疾病";
        }
    }

    /**
     * 案件状态: 1受理中 2已提交保司 3已结案 4已撤销 5诉讼中
     * @param type
     * @return
     */
    @Named("convertCaseStatus")
    public static String convertCaseStatus(Integer type) {
        if(null == type){
            return null;
        }
        switch (type){
            case 1:
                return "受理中";
            case 2:
                return "已提交保司";
            case 3:
                return "已结案";
            case 4:
                return "已撤销";
            default:
                return "诉讼中";
        }
    }

    /**
     * // 伤残鉴定级别（1~10）
     * @param type
     * @return
     */
    @Named("convertDisabilityAppraisalLevel")
    public static String convertDisabilityAppraisalLevel(Integer type) {
        if(null == type){
            return null;
        }
        switch (type){
            case -1:
                return "无";
//            case 0:
//                return "零级";
            case 1:
                return "一级";
            case 2:
                return "二级";
            case 3:
                return "三级";
            case 4:
                return "四级";
            case 5:
                return "五级";
            case 6:
                return "六级";
            case 7:
                return "七级";
            case 8:
                return "八级";
            case 9:
                return "九级";
            case 10:
                return "十级";
            default:
                return null;
        }
    }

    /**
     * 事故责任
     * @param type
     * @return
     */
    @Named("convertAccidentLiability")
    public static String convertAccidentLiability(Integer type) {
        if(null == type){
            return null;
        }
        switch (type){
            case 1:
                return "主要责任";
            case 2:
                return "次要责任";
            case 3:
                return "同等责任";
            case 4:
                return "全责";
            case 5:
                return "无责";
            default:
                return null;
        }
    }

    @Named("convertTreatmentType")
    public static String convertTreatmentType(Integer type) {
        if(null == type){
            return null;
        }
        switch (type){
            case 1:
                return "门诊";
            case 2:
                return "住院";
            default:
                return null;
        }
    }

    @Named("joinTime")
    public static String joinTime(Date startTime, Date endTime){
        if(null == startTime && null == endTime){
            return null;
        }
        String s1 = "",s2 = "";
        String forStr = "yyyy-MM-dd HH:mm:ss";
        if(null != startTime){
            s1 = DateUtil.format(startTime, forStr);
        }
        if(null != endTime){
            s2 = DateUtil.format(endTime, forStr);
        }
        return s1 + "~"+ s2;
    }


    /**
     * 是否涉及二次治疗：1是 0否
     * @param type
     * @return
     */
    @Named("convertTreatAgainFlag")
    public static String convertTreatAgainFlag(Integer type) {
        if(null == type){
            return null;
        }
        return type == 1 ? "是":"否";
    }
}
